<?php
// +---------------------------------------------------------------------+
// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | Bigotry <3162875@qq.com>                               |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/OneBase                      |
// +---------------------------------------------------------------------+

namespace app\admin\controller;

/**
 * 加入班级控制器
 */
class Join extends AdminBase
{
    
    /**
     * 加入设置
     */
    public function setting()
    {
        
        IS_POST && $this->jump($this->logicConfig->settingSave($this->param));
        
        $where = empty($this->param['group']) ? ['group' => 1] : ['group' => $this->param['group']];
        
        $this->getConfigCommonData();
        $this->assign('group', $where['group']);
        
        return  $this->fetch('setting');
    }

    /**
     * 配置列表
     */
    public function joinList()
    {
        
        $this->getConfigCommonData();
        
        $data = $this->logicJoin->getConfigListFilter($this->param);
        $this->assign('group', $data['group']);
        
        return $this->fetch('join_list');
    }
    
    /**
     * 获取通用数据
     */
    public function getConfigCommonData()
    {
        
        $join_group_list = parse_config_array('join_group_list'); 
        $join_class_list = parse_config_array('join_class_list');      
        $this->assign('join_group_list', $join_group_list);
        $this->assign('join_class_list', $join_class_list);
    }
    
    /**
     * 配置添加
     */
    public function joinAdd()
    {
        
        IS_POST && $this->jump($this->logicConfig->joinAdd($this->param));
        
        $this->getConfigCommonData();
        
        !empty($this->param['group']) && $this->assign('info', ['group'=> $this->param['group']]);
        
        return  $this->fetch('join_edit');
    }
    
    /**
     * 配置编辑
     */
    public function joinEdit()
    {
        
        IS_POST && $this->jump($this->logicConfig->joinEdit($this->param));
        
        $info = $this->logicConfig->getConfigInfo(['id' => $this->param['id']]);
        
        $this->assign('info', $info);
        
        $this->getConfigCommonData();
        
        return $this->fetch('join_edit');
    }
}
